#include "searcher.hpp"
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
const std::string input = "data/raw_html/raw.txt";

int main()
{
	//for test
	ns_searcher::Searcher* search = new ns_searcher::Searcher();
	search->InitSearcher(input);

	std::string query,json_string;
	char buffer[1024];
	while(true)
	{	
		std::cout << "Please Enter Your Search Query:";
		fgets(buffer,sizeof(buffer)-1,stdin);
		buffer[strlen(buffer)-1] = 0;//去掉用户最后输入的回车换行符
		query = buffer;
		//如果用cin，会以空格作为分隔符，输入空格会造成错误。所以这里用fgets
		//std::cin >> query;
		search->Search(query,&json_string);

		std::cout << json_string << std::endl;
	}
	return 0;
}
